<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
      <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  </head>
  <script>var contentIndex,contentIndex1,contentIndex2,contentIndex3;
  </script><body>
    <div class="x-body">
        <form class="layui-form">
            <input type="hidden" name="idxProAdmin" id="idxProAdmin" value="${id}"/>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    开始时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="beginTime" name="beginTime"
                           autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    结束时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="endTime" name="endTime"
                           autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    距离结束时间天数
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="differenceTime" name="differenceTime"
                           autocomplete="off" class="layui-input" disabled style="background-color: #b7b1b1;">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>客户名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="customerName" name="customerName" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" disabled >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="constructionUnit" class="layui-form-label">
                    <span class="x-red">*</span>施工单位
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="constructionUnit" name="constructionUnit" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="reExaminationType" class="layui-form-label">
                    <span class="x-red">*</span>类别
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="reExaminationType" name="reExaminationType" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="checkAcceptanceProName" class="layui-form-label">
                    <span class="x-red">*</span>验收项目
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="checkAcceptanceProName" name="checkAcceptanceProName" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="content" class="layui-form-label">
                    <span class="x-red">*</span>存在问题
                </label>
                <div class="layui-input-inline">
                    <textarea id="content"  name="existingProblems" style="display: none;"
                              class="layui-hide"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="content1" class="layui-form-label">
                    <span class="x-red">*</span>与图纸不符(施工，设备)
                </label>
                <div class="layui-input-inline">
                    <textarea id="content1"  name="designChartDiscrepancy" style="display: none;"
                              class="layui-hide"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerName" class="layui-form-label">
                    <span class="x-red">*</span>整改意见（遗留问题）
                </label>
                <div class="layui-input-inline">
                    <textarea id="content2"  name="amendments" style="display: none;"
                              class="layui-hide"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="organizationalUnit" class="layui-form-label">
                    <span class="x-red">*</span>组织单位
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="organizationalUnit" name="organizationalUnit" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <label for="acceptanceUnit" class="layui-form-label">
                    <span class="x-red">*</span>验收单位
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="acceptanceUnit" name="acceptanceUnit" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" >
                </div>
            </div>

            <div class="layui-form-item">
                <label for="organizationalUnitCharge" class="layui-form-label">
                    <span class="x-red">*</span>组织单位负责人
                </label>
                <div class="layui-input-inline">
                    <img class="layui-upload-img" src="" id="imgUrl11" width="100px" /><br><br><br>
                    <input type="hidden" id="organizationalUnitCharge" name="organizationalUnitCharge"  >
                    <button type="button" class="layui-btn" id="upload11">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button><script>
                    updateFile("upload11","imgUrl11","organizationalUnitCharge");
                </script>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="constructionPersonCharge" class="layui-form-label">
                    <span class="x-red">*</span>施工负责人
                </label>
                <div class="layui-input-inline">
                    <img class="layui-upload-img" src="" id="imgUrl12" width="100px" /><br><br><br>
                    <input type="hidden" id="constructionPersonCharge" name="constructionPersonCharge"  >
                    <button type="button" class="layui-btn" id="upload12">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button><script>
                    updateFile("upload12","imgUrl12","constructionPersonCharge");
                </script>
                </div>
            </div>



            <div class="layui-form-item">
                <label for="acceptanceUnitCharge" class="layui-form-label">
                    <span class="x-red">*</span>验收单位负责人
                </label>
                <div class="layui-input-inline">
                    <img class="layui-upload-img" src="" id="imgUrl13" width="100px" /><br><br><br>
                    <input type="hidden" id="acceptanceUnitCharge" name="acceptanceUnitCharge"  >
                    <button type="button" class="layui-btn" id="upload13">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button><script>
                    updateFile("upload13","imgUrl13","acceptanceUnitCharge");
                </script>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="customerPersonCharge" class="layui-form-label">
                    <span class="x-red">*</span>客户负责人
                </label>
                <div class="layui-input-inline">
                    <img class="layui-upload-img" src="" id="imgUrl14" width="100px" /><br><br><br>
                    <input type="hidden" id="customerPersonCharge" name="customerPersonCharge"  >
                    <button type="button" class="layui-btn" id="upload14">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button><script>
                    updateFile("upload14","imgUrl14","customerPersonCharge");
                </script>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="livePhotos1" class="layui-form-label">
                    <span class="x-red">*</span>现场照片上传：<br/>
                    <div style="color: #797474;margin-top: 9px;">注：上传图片</div>
                </label>
                <div class="layui-input-inline" >
                    <br>
                    <img class="layui-upload-img" src="" id="imgUrl" width="100px" /><br><br><br>
                    <input type="hidden" name="livePhotos" id="livePhotos1" >
                    <button type="button" class="layui-btn" id="upload">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button>
                    <script>
                    updateFile("upload1","imgUrl1g","livePhotos1");
                    </script>
                    <br>
                    <img class="layui-upload-img" src="" id="imgUrl2" width="100px" /><br><br><br>
                    <input type="hidden" name="livePhotos" id="livePhotos2"   >
                    <button type="button" class="layui-btn" id="upload2">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button>
                    <script>
                    updateFile("upload2","imgUrl2","livePhotos2");
                    </script>

                    <br>
                    <img class="layui-upload-img" src="" id="imgUrl3" width="100px" /><br><br><br>
                    <input type="hidden" name="livePhotos" id="livePhotos3"   >
                    <button type="button" class="layui-btn" id="upload3">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button>
                    <script>
                        updateFile("upload3","imgUrl3","livePhotos3");
                    </script>
                    <br>
                    <img class="layui-upload-img" src="" id="imgUrl4" width="100px" /><br><br><br>
                    <input type="hidden" name="livePhotos" id="livePhotos4"   >
                    <button type="button" class="layui-btn" id="upload4">
                        <i class="layui-icon">&#xe67c;</i>上传文件
                    </button>
                    <script>
                        updateFile("upload4","imgUrl4","livePhotos4");
                    </script>
                </div>
            </div>


            <div class="layui-form-item">
                <label for="" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="preservation" type=button codeTyle="1" lay-submit="">
                    保存
                </button>
                <button  class="layui-btn" lay-filter="preAdd" type=button codeTyle="2" lay-submit="">
                    预提交
                </button>
                <button  class="layui-btn" lay-filter="add" type=button codeTyle="3" lay-submit="">
                    提交
                </button>
            </div>
      </form>
    </div>
    <script>
        getProTime($("#idxProAdmin").val(),40);
        ajaxFun('get','/pc/project/getProjectBaseInfo',{"idProAdmin":$("#idxProAdmin").val()},function(data){
            if(data.code != 0){
                alertFun(data);
            }else{
                $("#customerName").val(data.data.customerName);
            }
        })
        var layedit = '';
        layui.use('layedit', function(){
            layedit = layui.layedit;
            layedit.set({
                uploadImage: {
                    url: path + '/pc/upload/uploadFile' //接口url
                    ,type: 'post' //默认post
                }
            });
            contentIndex = layedit.build("content"); //建立编辑器
            contentIndex1 = layedit.build("content1"); //建立编辑器
            contentIndex2 = layedit.build("content2"); //建立编辑器
        });
        layui.use(['form','layer'], function() {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer, layedit = layui.layedit;

            //自定义验证规则
            form.verify({});

            //监听提交
            form.on('submit(add)', function (t) {
                addSubmit(3);
            });

            //监听保存
            form.on('submit(preservation)', function (t) {
                addSubmit(1);
            });

            //监听预提交
            form.on('submit(preAdd)', function (t) {
                addSubmit(2);
            });

        });

        function addSubmit(submitState){

            var livePhotos=new Array(),i = 0;
            $("input[name='livePhotos']").each(function(){
                if(isNotNull($(this).val())) {
                    var data = {
                        idSysFiles: $(this).val(),
                        resourcesType: 1
                    };
                    livePhotos[i] = data;
                    i++;
                }
            })

            var params = {
                //tcaDescribe : layui.layedit.getContent(index),
                "idProAdmin": $("#idxProAdmin").val(),
                "testType": 2,
                "constructionUnit": $("#constructionUnit").val(),
                "reExaminationType": $("#reExaminationType").val(),
                "checkAcceptanceProName": $("#checkAcceptanceProName").val(),

                "organizationalUnit": $("#organizationalUnit").val(),
                "organizationalUnitCharge": $("#organizationalUnitCharge").val(),
                "constructionPersonCharge": $("#constructionPersonCharge").val(),
                "acceptanceUnit": $("#acceptanceUnit").val(),
                "acceptanceUnitCharge": $("#acceptanceUnitCharge").val(),
                "customerPersonCharge": $("#customerPersonCharge").val(),
                "livePhotosList":livePhotos,
                "existingProblems" : layedit.getContent(contentIndex),
                "designChartDiscrepancy" : layedit.getContent(contentIndex1),
                "amendments" : layedit.getContent(contentIndex2),
                "submitState":submitState
            }
            if (true) {
                ajaxFunJson('post','/pc/project/addIntermediateInspection',JSON.stringify(params),function(data){
                    if (data.code != 0) {
                        alertFun(data);
                    } else {
                        window.location.href = path + "/modules/project/threePro/jgys/list.html";
                        console.log("success !");
                    }
                })
                return false;
            }
        }
    </script></body></html>